package com.yc.bestMatching;

import java.io.File;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestMain {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        String path=System.getProperty("user.home");
        path=path+ File.separator+"bestMatching"+File.separator+"UK Advanced Cryptics Dictionary.txt";
        //System.out.println(path);

        List<String>list=WordsLoader.load(path);
        //System.out.println(list.size());


        String word="sit";

        BestMatchingTask task=new BestMatchingTask(list,word,0,list.size());
        FutureTask<BestMatchingData> futureTask=new FutureTask<>(task);
        Thread t=new Thread(futureTask);
        t.start();

        BestMatchingData bestMatchingData=futureTask.get(); //get()阻塞式方法 只有任务运行玩完了 才可以得到结构 程序继续往下
        System.out.println(bestMatchingData.getDistance()+"  "+  bestMatchingData.getWords());
    }
}
